package com.example.cameraxdemo

import android.graphics.BitmapFactory
import android.net.Uri
import android.os.Bundle
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions

/**
 * author : king_nina
 * e-mail : 13450414852@163.com
 * date   : 2021/11/30
 * desc   :
 */

public const val PREVIEW_PATH = "preview_path"

class PreviewActivity : AppCompatActivity() {

    private lateinit var preview: ImageView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_preview)
        initView()
    }

    private fun initView() {
        val path: String? = intent.getStringExtra(PREVIEW_PATH)
        preview = findViewById(R.id.preview)
        path?.let {
            val uri = Uri.parse(path)
            Glide.with(this)
                .load(uri)
                .apply(RequestOptions.fitCenterTransform())
                .into(preview)
        }
    }
}